package org.frv.wispr.web.account;

import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.PageParameters;
import org.apache.wicket.security.hive.authentication.LoginContext;
import org.apache.wicket.security.strategies.LoginException;
import org.apache.wicket.security.WaspSession;

/**
 * Created by IntelliJ IDEA.
 * User: frank
 * Date: Jan 8, 2008
 * Time: 7:41:48 PM
 * To change this template use File | Settings | File Templates.
 */
// this page needs to become SSL to make sure login is save
public class LoginPage extends WebPage {

    public LoginPage() {
        setStatelessHint(true);
        add(new FeedbackPanel("feedback") {
            public boolean isVisible() {
                return anyMessage();
            }
        });
        // feedback for later if something goes wrong
        add(new WisprLoginPanel("login_panel") {
            public boolean signIn(String username, String password) {
  				LoginContext ctx = new UserContext(username, password);
				try {
                    ((WisprSession)getSession()).login(ctx);
                } catch (LoginException e) {
                    
                    return false;
				}
				return true;
			}
        });
    }
//		setStatelessHint(true);
//		add(new FeedbackPanel("feedback") {
//			public boolean isVisible() {
//				return anyMessage();
//			}
//		});
//		String panelId = "signInPanel";
//		newUserPasswordSignInPanel(panelId);
//    }
//
//    protected void newUserPasswordSignInPanel(String panelId) {
//		add(new UsernamePasswordSignInPanel(panelId) {
//            public boolean signIn(String username, String password)
//			{
//				LoginContext ctx = new UserContext(username, password);
//				try
//				{
//					((WaspSession)getSession()).login(ctx);
//				}
//				catch (LoginException e)
//				{
//					return false;
//				}
//				return true;
//			}
//		});
//	}
}
